/***************************************************************************
 *   Copyright (C) 2007 by Alexandre Masselot,,,   *
 *   alex@alex-laptop   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef PEPTIDEMODIFIER_H
#define PEPTIDEMODIFIER_H
#include <iostream>
#include <map>
#include "assert.h"
#include "boost/tokenizer.hpp"

#include "modificationdictionary.h"
#include "peptide.h"
/**
	@author Alexandre Masselot,,, <alex@alex-laptop>
*/
namespace bol{
class PeptideModifier{
  /**
   * number of defined reduched char
   */
  unsigned char m_cptChar;
  /**
   * map reduced unmodified char onto their modified reduced char counterpart. In case of fixed modification, direct link to the reduced modified char (represented as a single element vector of unsigned char). In case of variable modification, a vector of unsigned char gives the list of possible modifications.
   */
  unsigned char *m_charMapper[29];
  /**
   * the amino acid corresponding to a given reduced char
   */
  unsigned char m_origChar[256];
  /**
   * a pointer to the modification carried by the reduced char
   */
  Modification *m_origModif[256];

  /**
   * a hash where the key is A-modifstring -> c
   * A in an amino acid
   * modifstring is the string for the modification
   * c is the unsigned char corresponding to the amino acid A modified
   */
  map<string, unsigned char> m_modifaadico;
  ModificationDictionary *m_modifdico;
public:
    PeptideModifier();

    ~PeptideModifier(){}

    /**
     * add a modification either variable or not (i.e. map the char to a char*);
     * @param mod 
     * @param  
     */
    void addModif(Modification* mod, const bool isVariable);

  
    /**
     * prints the peptide in a human readable manner on the stream. Modifications will be embeded in the sequence, except if the Peptide pointer is towards a PeptidePMF
     * @param out 
     * @param pept 
     */
    void printPeptide(ostream& out, const Peptide *pept);

    
    /**
     * build a Peptide object based on a basic sequence of length l and a set of l+2 modif (a string serated by ':)
     * @param sequence 
     * @param modifs 
     * @return 
     */
    Peptide* peptide(const string sequence, const string modifs);

    friend ostream& operator<<(ostream& out, const PeptideModifier& pm);

  unsigned char** charMapper() {
      return m_charMapper;
  }

  void setModifdico(ModificationDictionary* theValue) {
      m_modifdico = theValue;
  }
  

  ModificationDictionary* modifdico() const {
      return m_modifdico;
  }
  
  
  
};
}
#endif
